<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org"
      xmlns:layout="http://www.ultraq.net.nz/web/thymeleaf/layout">
    <head>
        <meta charset="UTF-8" />
        <title>近近 - 上传视频</title>
        <link rel="stylesheet" type="text/css" media="all" href="/layui/css/layui.css"/>
        <script type="text/javascript" src="/layui/layui.all.js"></script>
        <script type="text/javascript" src="/js/jquery.min.js"></script>
        <!--<script type="text/javascript" src="/js/myJs.js"></script>-->
    </head>
    <body>

        <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
            <legend>近近 - 上传视频</legend>
        </fieldset>

        <div class="layui-container">
            <!--6/12 布局-->
            <div class="layui-row">
                <div class="layui-col-xs6" id="uploadFrame">
                    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
                        <legend>拖拽上传</legend>
                    </fieldset>

                    <div class="layui-upload-drag" id="test10">
                        <i class="layui-icon"></i>
                        <p>点击上传，或将文件拖拽到此处</p>
                    </div>
                </div>
            </div>
        </div>
    </body>
    <script>
        layui.use('upload', function(){
            var $ = layui.jquery
                ,upload = layui.upload;

            //拖拽上传
            upload.render({
                elem: '#test10'
                ,url: '/upload/'
                ,accept: 'file'
                ,multiple: true
                ,before: function(obj){
                    layer.load();
                }
                ,done: function(res, index, upload){
                    if (res.code == 0) {
                        layer.closeAll('loading');
                        var qiniuAddress = res.data.src;
                        layer.alert("成功! 上传地址为: " + qiniuAddress);
                        $("#uploadFrame").append("<div><a href='" + qiniuAddress + "' target='_blank'>点击查看</a></div>");
                    } else {
                        layer.alert("上传出错!");
                    }
                }
            });
        });
    </script>
</html>